<?php
	$name 		= $this->formText('name',$this->Item['name'],array('class'=>'txtmedium')); 
	$options 	= array(2=>'Chọn kiểu sản phẩm',0=>'Không đặc biệt',1=>'Đặc biệt');
	$special	= $this->formSelect('special',$this->Item['special'], null, $options);
	
	$options 	= array(2=>'Chọn trạng thái',0=>'Không kích hoạt',1=>'Kích hoạt');
	$status		= $this->formSelect('status',$this->Item['status'], null, $options);
	
	$price 		= $this->formText('price',$this->Item['price'],array('class'=>'txtmedium'));
	$selloff 	= $this->formText('selloff',$this->Item['selloff'],array('class'=>'txtmedium'));
	$publisher 	= $this->formText('publisher',$this->Item['publisher'],array('class'=>'txtmedium'));
	$translators= $this->formText('translators',$this->Item['translators'],array('class'=>'txtmedium'));
	$weight     = $this->formText('weight',$this->Item['weight'],array('class'=>'txtshort'));
	$size 		= $this->formText('size',$this->Item['size'],array('class'=>'txtshort'));
	$page       = $this->formText('page',$this->Item['page'],array('class'=>'txtshort'));
	$order      = $this->formText('order',$this->Item['order'],array('class'=>'txtshort'));
	
	$author 	= $this->formText('author',$this->Item['author'],array('class'=>'txtmedium'));
		
	$content 	= $this->cmsEditor('content',$this->Item['content'],array('toolbar'=>'Default','language'=>'vi'),'100%','500px');
	$content 	= $this->cmsReplaceString($content);
	
	$cat_id   	= $this->cmsSelect('cat_id',$this->Item['cat_id'],$this->SelectCategory,
									array('size'=>10,'style'=>'min-width:200px;')
									);
	
	$dayOptions = array(0=>'Ngày');
	for ($i = 1; $i < 32; $i++){
		$dayOptions[$i] = $i;
	}	
	$monthOptions = array(0=>'Tháng');
	for ($i = 1; $i < 13; $i++){
		$monthOptions[$i] = $i;
	}	
	$yearOptions = array(0=>'Năm');
	$y = date('Y', time()) - 4;
	for ($i = $y; $i > 1924; $i--){
		$yearOptions[$i] = $i;
	}
	if($this->flag==true){	
		$day  			= $this->formSelect('day', date('d', strtotime($this->Item['publish_date'])),NULL, $dayOptions);
		$month  		= $this->formSelect('month', date('m', strtotime($this->Item['publish_date'])), NULL, $monthOptions);
		$year  			= $this->formSelect('year', date('Y', strtotime($this->Item['publish_date'])), NULL, $yearOptions);
		$publish_date = $day. ' ' .$month . ' ' .$year;
	}else{
		$day  			= $this->formSelect('day', $this->Item['day'],NULL, $dayOptions);
		$month  		= $this->formSelect('month', $this->Item['month'], NULL, $monthOptions);
		$year  			= $this->formSelect('year', $this->Item['year'], NULL, $yearOptions);
		$publish_date = $day. ' ' .$month . ' ' .$year;
	}
	if(!empty($this->Item['pic'])){
		$current_picture = $this->formHidden('current_picture',$this->Item['pic']);
		$picture = $this->formFile('picture',array('style'=>'width:250px;'));
		$linkPicture	= FILES_URL. '/product/img82x122/'. $this->Item['pic'];
		$picture.='<br><img src ="'.$linkPicture.'"><br>'. $this->Item['picture']. $current_picture ;
		
	}else{
			$current_picture = $this->formHidden('current_picture',$this->Item['picture']);
			$picture = $this->formFile('picture',array('style'=>'width:250px;'));
			if(!empty($this->Item['picture'])){
				$linkPicture	= FILES_URL. '/product/img82x122/'. $this->Item['picture'];
				$picture.='<br><img src ="'.$linkPicture.'"><br>'. $this->Item['picture']. $current_picture ;
			}
	}
	
	$arrInput = array(
			array('lable'=>'Tên Sách:','input'=>$name),
			array('lable'=>'Hình ảnh:','input'=>$picture ,'style'=>'margin-left: 175px;'),
			array('lable'=>'Tác giả:','input'=>$author ),
			array('lable'=>'Dịch giả:','input'=>$translators ),
			array('lable'=>'Nhà xuất bản:','input'=>$publisher ),
			array('lable'=>'Giá bán:','input'=>$price ),
			array('lable'=>'Giá khuyến mại:','input'=>$selloff ),
			array('lable'=>'Sản phẩm đặc biệt:','input'=>$special ),
			array('lable'=>'Trạng thái:','input'=>$status ),
			array('lable'=>'Giá trị:','input'=>$order ),
			array('lable'=>'Trọng lượng:','input'=>$weight ),
			array('lable'=>'Kích thước:','input'=>$size ),
			array('lable'=>'Số trang:','input'=>$page ),
			array('lable'=>'Ngày xuất bản:','input'=>$publish_date ),
			array('lable'=>'Thuộc mục:','input'=>$cat_id ),
			array('lable'=>'Nội dung:','input'=>$content ,'style'=>'margin-left: 175px;'),
	);
		
					
	////////MESSAGES ERRORS//////////////////
	if(count($this->arrErrors)>0){
		$errors = $this->formErrors($this->arrErrors,array('id'=>'errors'));
	}
?>
<form name="appForm" method="post" action="" enctype="multipart/form-data">
						 <?php echo $this->render('admin-product/toolbar/index.php')?>
                        <div class="clr"></div>
                         <?php echo $this->render('admin-product/sublink/index.php')?>
                            <!-- IN RA LOI KHI VALIDATE -->
                         	<?php if(isset($errors)) echo $errors;?>
                         	
                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                            </div>
                            <div class="m">
                                <!-- BEGIN: ELEMENT BOX -->
                              <div id="adminfieldset">
                                 <div class="adminheader">Chi tiết</div>
									<?php echo $this->partialLoop('row.php',$arrInput);?>
	                           </div>
	                           
	                          

                                <!-- END: ELEMENT BOX -->	
                              <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->
                    </form>